package com.mobilg.client.xml.parser;


import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class MyXMLShopHandler extends DefaultHandler {

Boolean currentElement = false;
String currentValue = null;
public static ShopsList shopsList = null;

public static ShopsList getShopsList() {
return shopsList;
}

public static void setShopsList(ShopsList shopsList) {
	MyXMLShopHandler.shopsList = shopsList;
}

/** Called when tag starts ( ex:- <name>AndroidPeople</name>
* -- <name> )*/
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {

currentElement = true;

if (localName.equals("shops"))
{
/** Start */
shopsList = new ShopsList();
} //else if (localName.equals("shop")) {
/** Get attribute value */
//String attr = attributes.getValue("identity");
//shopsList.setIdentity(attr);
//}

}

/** Called when tag closing ( ex:- <name>AndroidPeople</name>
* -- </name> )*/
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {

currentElement = false;

/** set value */
if (localName.equalsIgnoreCase("identity"))
	shopsList.setIdentity(currentValue);
else if (localName.equalsIgnoreCase("name"))
	shopsList.setName(currentValue);
else if (localName.equalsIgnoreCase("logoSmall"))
	shopsList.setLogo_small(currentValue);
else if (localName.equalsIgnoreCase("categoryIdentity"))
	shopsList.setCategoryIdentity(currentValue);

}

/** Called to get tag characters ( ex:- <name>AndroidPeople</name>
* -- to get AndroidPeople Character ) */
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {

if (currentElement) {
currentValue = new String(ch, start, length);
currentElement = false;
}

}

}